<template>
  <a-form :form="form" >
    <a-row :gutter="md">
<!--      <a-col :md="12" :sm="12">
        <a-form-item
          label="学号"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
        >
          <a-input v-decorator="[
            'xh',
            {
              rules: [{ required: true, message: '请输入学号!' }],
            }
          ]"/>
        </a-form-item>
      </a-col>-->
      <a-col :md="md" :sm="12">
        <a-form-item
          label="入学年月"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-date-picker v-decorator="['rxny']" style="width: 100%"  format="YYYY-MM-DD"/>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="学生类别"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select @change="xslbChange" :allowClear="true" v-decorator="['xslbm', {rules: [{ required: true, message: '请选择学生类别!' }]}]">
            <a-select-option v-for="i in TYPE0075" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
          <a-input v-decorator="['xslbmc']" type="hidden"/>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="学制"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select v-decorator="['xz', {rules: [{ required: true, message: '请选择学制!' }]}]">
            <a-select-option v-for="i in TYPE0301" :key="i.id" :value="String(i.code)">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="所在年级"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select @change="sznjChange" :allowClear="true" v-decorator="['sznj', {rules: [{ required: true, message: '请选择所在年级!' }]}]">
            <a-select-option v-for="i in TYPE0126" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="所属院系"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true" v-decorator="['ssyxm', {rules: [{ required: true, message: '请选择所属院系!' }]}]" showSearch @change="yxChange" :filterOption="filterOption">
            <a-select-option v-for="i in selectMenu.yx" :key="i.id" :value="i.dwh">{{ i.dwh }} {{ i.dwmc }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="所属专业"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true" v-decorator="['sszym', {rules: [{ required: true, message: '请选择所属专业!' }]}]" showSearch :filterOption="filterOption" @change="zyChange">
            <a-select-option v-for="i in selectMenu.zy" :key="i.id" :value="i.zyh">{{ i.zyh}} {{ i.zymc }}</a-select-option>
          </a-select>
          <a-input v-decorator="['sszymc']" type="hidden"/>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="所在班号"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-input v-decorator="['szbh']"/>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="是否全日制"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true" v-decorator="['isqrz']">
            <a-select-option v-for="i in TYPE0441" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="学籍状态"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true" v-decorator="['xjztm', {rules: [{ required: true, message: '请选择学籍状态!' }]}]">
            <a-select-option v-for="i in TYPE0073" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="培养模式"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true" v-decorator="['pymsm', {rules: [{ required: true, message: '请选择培养模式!' }]}]">
            <a-select-option v-for="i in TYPE0347" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="培养方式"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select @change="pyfsChange" :allowClear="true" v-decorator="['pyfsm', {rules: [{ required: true, message: '请选择培养方式!' }]}]">
            <a-select-option v-for="i in TYPE0059" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="财务编号"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-input v-decorator="['cwbh']"/>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="录取类别"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true" v-decorator="['lqlbm', {rules: [{ required: true, message: '请选择录取类别!' }]}]">
            <a-select-option v-for="i in TYPE0362" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="第一导师"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
<!--          <a-select
            v-decorator="['dszgh', {rules: [{ required: true, message: '请选择第一导师!' }]}]"
            placeholder="可输入导师编号或姓名搜索"
            :filterOption="false"
            @search="fetchDyds"
            showSearch
            :notFoundContent="dyds.fetching ? undefined : null"
            allowClear
          >
            <a-spin v-if="dyds.fetching" slot="notFoundContent" size="small"/>
            <a-select-option v-for="i in dyds.list" :key="i.gh" :value="i.gh">{{i.xm}}</a-select-option>
          </a-select>-->
          <a-select :allowClear="true" v-decorator="['dszgh', {rules: [{ required: true, message: '请选择第一导师!' }]}]" showSearch :filterOption="filterOption">
            <a-select-option v-for="i in selectMenu.dsList" :key="i.dsbh" :value="i.dsbh">{{ i.xm }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="第二导师"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
<!--          <a-select
            v-decorator="['dedszgh']"
            placeholder="可输入导师编号或姓名搜索"
            :filterOption="false"
            @search="fetchDeds"
            showSearch
            :notFoundContent="deds.fetching ? undefined : null"
            allowClear
          >
            <a-spin v-if="deds.fetching" slot="notFoundContent" size="small"/>
            <a-select-option v-for="i in deds.list" :key="i.gh" :value="i.gh">{{i.xm}}</a-select-option>
          </a-select>-->
          <a-select :allowClear="true" v-decorator="['dedszgh']" showSearch :filterOption="filterOption">
            <a-select-option v-for="i in selectMenu.dsList" :key="i.dsbh" :value="i.dsbh">{{ i.xm }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="培养分类"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true" v-decorator="['pyflm']">
            <a-select-option v-for="i in TYPE0120" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="导师职称"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true" v-decorator="['dszcm']">
            <a-select-option v-for="i in TYPE0342" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="第二导师职称"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true" v-decorator="['dedszcm']">
            <a-select-option v-for="i in TYPE0342" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="分院"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-input v-decorator="['fy']"/>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="入学方式"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true" v-decorator="['rxfs']">
            <a-select-option v-for="i in TYPE0064" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="来源国"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true" v-decorator="['lygbm']">
            <a-select-option v-for="i in TYPE0015" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item style="width:100%" label="来源地区"
                     :labelCol="{span: 6,offset: 1}"
                     :wrapperCol="{span: 16, offset: 1}"
                     selfUpdate>
            <a-select style="width:33%" @change="provinceChange" v-decorator="['lydqms']" :allowClear="true">
              <a-select-option v-for="i in selectMenu.province" :key="i.areaCode" :value="String(i.areaCode)">{{ i.name }}</a-select-option>
            </a-select>
            <a-select style="width:33%" @change="cityChange" v-decorator="['lydqmc']" :allowClear="true">
              <a-select-option v-for="i in selectMenu.city" :key="i.areaCode" :value="String(i.areaCode)">{{ i.name }}</a-select-option>
            </a-select>
            <a-select style="width:33%" v-decorator="['lydqmxq']" :allowClear="true">
              <a-select-option v-for="i in selectMenu.area" :key="i.areaCode" :value="String(i.areaCode)">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="培养层次"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true"  @change="pyccmChange" v-decorator="['pyccm', {rules: [{ required: true, message: '请选择培养层次!' }]}]">
            <a-select-option v-for="i in TYPE0310" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="招生季节"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true" v-decorator="['zzjj']">
            <a-select-option v-for="i in TYPE0309" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="研究方向"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true" v-decorator="['yjfx']">
            <a-select-option v-for="i in selectMenu.yjfx" :key="i.id" :value="i.yjfxm">{{ i.yjfxm + ' ' + i.yjfxmc }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="学习形式"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true" v-decorator="['xxxsm']">
            <a-select-option v-for="i in TYPE0307" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="借书证号"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-input v-decorator="['jszh']"/>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="考生编号"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-input v-decorator="['ksbh', {rules: [{ required: true, message: '请填写考生编号!' }]}]"/>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="考生报名号"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-input v-decorator="['ksbmh']"/>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="定向或委培单位"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-input v-decorator="['dxhwpdw', {rules: [{ required: pyfsm == '12', message: '定向或委培单位!' }]}]"/>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="参加工作时间"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-date-picker v-decorator="['gzsj']" style="width: 100%" format="YYYY-MM-DD"/>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="工作单位"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-input v-decorator="['gzdw']"/>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="职务"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-input v-decorator="['zw']"/>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="职称"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-input v-decorator="['zc']"/>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="培养单位名称"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-input v-decorator="['pydwmc']"/>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="办学形式"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true" v-decorator="['bxxsm']">
            <a-select-option v-for="i in TYPE0333" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="办学类型"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true" v-decorator="['bxlxm']">
            <a-select-option v-for="i in TYPE0030" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
          <a-input v-decorator="['bxxs']" type="hidden"/>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="学校所在地名称"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-input v-decorator="['xxszdmc']"/>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="毕业年月"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select v-decorator="['byny']" allowClear>
            <a-select-option v-for="i in graduateYearList" :key="i" :value="i">{{i}}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="学科"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true" v-decorator="['xkm']" >
            <a-select-option v-for="i in TYPE0090" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="学业奖学金等级"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true" v-decorator="['xyjxjdjm']">
            <a-select-option v-for="i in TYPE0311" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="助研奖学金等级"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true" v-decorator="['zyjxjdjm']">
            <a-select-option v-for="i in TYPE0312" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="学历"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
          selfUpdate
        >
          <a-select :allowClear="true" v-decorator="['xlm']">
            <a-select-option v-for="i in TYPE0018" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
    </a-row>
<!--    <a-row>
      <a-col :md="md" :sm="12">
        <a-form-item
          label="备注"
          :labelCol="{span: 6,offset: 1}"
          :wrapperCol="{span: 16, offset: 1}"
        >
          <a-input v-decorator="['note']"/>
        </a-form-item>
      </a-col>
    </a-row>-->
  </a-form>
</template>
<script>
import { mapState } from 'vuex'
const selectArr = ['TYPE0018', 'TYPE0301', 'TYPE0312', 'TYPE0311', 'TYPE0309', 'TYPE0333', 'TYPE0030', 'TYPE0307',
  'TYPE0310', 'TYPE0015', 'TYPE0064', 'TYPE0342', 'TYPE0362', 'TYPE0059', 'TYPE0347', 'TYPE0073', 'TYPE0075',
  'TYPE0126', 'TYPE0441', 'TYPE0120','TYPE0090']
export default {
  props: {
    xjxx: {
      type: Object,
      default: () => {}
    }
  },
  // props: ['xjxx'],
  data () {
    return {
      md: (12),
      selectMenu: {},
      pyfsm: '',
      graduateYearList: []
  }
  },
  computed: {
    ...mapState({
      TYPE0126: state => state.app['TYPE0126'], // 年级
      TYPE0075: state => state.app['TYPE0075'], // 学生类别
      TYPE0073: state => state.app['TYPE0073'], // 学生当前状态
      TYPE0347: state => state.app['TYPE0347'], // 培养模式
      TYPE0059: state => state.app['TYPE0059'], // 培养方式
      TYPE0362: state => state.app['TYPE0362'], // 录取类别
      TYPE0342: state => state.app['TYPE0342'], // 导师职称
      TYPE0064: state => state.app['TYPE0064'], // 入学方式
      TYPE0015: state => state.app['TYPE0015'], // 来源国
      TYPE0310: state => state.app['TYPE0310'], // 培养层次
      TYPE0307: state => state.app['TYPE0307'], // 学习形式
      TYPE0333: state => state.app['TYPE0333'], // 办学形式
      TYPE0030: state => state.app['TYPE0030'], // 办学类型
      TYPE0311: state => state.app['TYPE0311'], // 学业奖学金等级
      TYPE0312: state => state.app['TYPE0312'], // 助研奖学金等级
      TYPE0018: state => state.app['TYPE0018'], // 学历
      TYPE0301: state => state.app['TYPE0301'], // 学制
      TYPE0309: state => state.app['TYPE0309'], // 招生季节
      TYPE0441: state => state.app['TYPE0441'],
      TYPE0120: state => state.app['TYPE0120'],
      TYPE0090: state => state.app['TYPE0090'],
    })
  },
  beforeCreate () {
    this.form = this.$form.createForm(this)
  },
  created () {
    const curYear = new Date().getFullYear()
    function generateYearArray (start, end) {
      let arr = []
      let len = end - start
      for (let index = 0; index < len; index++) {
        arr.push(...[`${start + index}-07-01`,`${start + index}-12-31`])
      }
      return arr
    }
    this.graduateYearList = generateYearArray(curYear-100,curYear+20)
    selectArr.forEach(v => {
      this.$store.dispatch('app/setDictionary', v)
    })
    this.initSelectMenu()
    if(this.xjxx){
      this.initFormXjxx()
    }
  },
  methods: {
    initFormXjxx(){
      this.$nextTick(() => {
        // if(this.xjxx.dszgh){
        //   this.fetchDyds(this.xjxx.dszgh)
        // }
        // if(this.xjxx.dedszgh){
        //   this.fetchDeds(this.xjxx.dedszgh)
        // }

        if (this.xjxx.lydqms) {
          this.provinceChange(this.xjxx.lydqms)
        }
        if (this.xjxx.lydqmc) {
          this.cityChange(this.xjxx.lydqmc)
        }
        if(this.xjxx.ssyxm){
          this.yxChange (this.xjxx.ssyxm)
        }
        if(this.xjxx.sszym){
          this.zyChange(this.xjxx.sszym)
        }
        if (this.xjxx.byny) {
          this.xjxx.byny = this.xjxx.byny.format('YYYY-MM-DD')
        }
        let keys = Object.keys(this.form.getFieldsValue())
        let obj = {}
        keys.forEach(key => {
          obj[key] = this.xjxx[key]
        })
        this.form.setFieldsValue(obj)
        this.pyfsm = this.form.getFieldValue('pyfsm')
      })
    },
    initSelectMenu () {
      let allRequest = [
        this.$api.base.areaList(),
        this.$api.base.collegeAll(),
        // this.$api.base.subjectAll({xklb: '01'}),
      ]
      Promise.all(allRequest).then(res => {
        this.selectMenu = {
          province: res[0].data,
          yx: res[1].data,
          // xk: res[2].data,
        }
      })
    },
    setData (option, key) {
      this.form.setFieldsValue({[key]: option.data.attrs.name})
    },
    provinceChange (v) {
      this.form.setFieldsValue({xzqhcdm: '', xzqhxdm: ''})
      if (v) {
        this.$api.base.areaList({parentCode: v}).then(res => {
          this.$set(this.selectMenu, 'city', res.data)
        })
      } else {
        this.$set(this.selectMenu, 'city', [])
      }
      this.$set(this.selectMenu, 'area', [])
    },
    pyccmChange(v){
      if(v){
        // 获取研究方向
        let ssyxm = this.form.getFieldValue('ssyxm')
        if(!ssyxm && this.xjxx){
          ssyxm = this.xjxx.ssyxm
        }
        let sszym  = this.form.getFieldValue('sszym')
        if(!sszym && this.xjxx){
          sszym = this.xjxx.sszym
        }
        let xslbm  = this.form.getFieldValue('xslbm')
        if(!xslbm && this.xjxx){
          xslbm = this.xjxx.xslbm
        }
        let sznj  = this.form.getFieldValue('sznj')
        if(!sznj && this.xjxx){
          sznj = this.xjxx.sznj
        }
        let xwccm  = this.getXwccm();
        this.fetchYjfx(ssyxm, sszym, sznj, xslbm,xwccm)
      }else{
        this.$set(this.selectMenu, 'yjfx', [])
      }
    },
    getXwccm(){
      let pyccm = this.form.getFieldValue('pyccm')
      if(pyccm === '432'){
        return 3;
      }
      if(pyccm === '431'){
        return 2;
      }
      return null;
    },
    cityChange (v) {
      this.form.setFieldsValue({xzqhxdm: ''})
      if (v) {
        this.$api.base.areaList({parentCode: v}).then(res => {
          this.$set(this.selectMenu, 'area', res.data)
        })
      } else {
        this.$set(this.selectMenu, 'area', [])
      }
    },
    pyfsChange (code) {
      this.pyfsm = code
    },
    yxChange (code) {
      this.form.setFieldsValue({sszym: ''})
      if (code) {
        this.$api.base.majorAll({lsdwh: code}).then(res => {
          this.$set(this.selectMenu, 'zy', res.data)
        })
      } else {
        this.$set(this.selectMenu, 'zy', [])
      }
    },
    zyChange (code){
      this.form.setFieldsValue({yjfx: ''})
      this.form.setFieldsValue({dszgh: ''})
      this.form.setFieldsValue({dedszgh: ''})
      if(code){
        // 获取研究方向
        // try {
          console.log(this.xjxx)
          let ssyxm = this.form.getFieldValue('ssyxm')
          if(!ssyxm && this.xjxx){
            ssyxm = this.xjxx.ssyxm
          }
          let sznj  = this.form.getFieldValue('sznj')
          if(!sznj && this.xjxx){
            sznj = this.xjxx.sznj
          }
          let xslbm  = this.form.getFieldValue('xslbm')
          if(!xslbm && this.xjxx){
            xslbm = this.xjxx.xslbm
          }
          let xwccm  = this.getXwccm()
          this.fetchYjfx(ssyxm, code, sznj, xslbm,xwccm)
          this.fetchDyds(ssyxm, code)
        // } catch (error) {
        //   console.log(error)
        // }
      }else{
        this.$set(this.selectMenu, 'yjfx', [])
        this.$set(this.selectMenu, 'dsList', [])
      }
    },
    sznjChange (code){
      this.form.setFieldsValue({yjfx: ''})
      if(code){
        // 获取研究方向
        let ssyxm = this.form.getFieldValue('ssyxm')
        if(!ssyxm && this.xjxx){
          ssyxm = this.xjxx.ssyxm
        }
        let sszym  = this.form.getFieldValue('sszym')
        if(!sszym && this.xjxx){
          sszym = this.xjxx.sszym
        }
        let xslbm  = this.form.getFieldValue('xslbm')
          if(!xslbm && this.xjxx){
            xslbm = this.xjxx.xslbm
        }
        let xwccm  = this.getXwccm()
        this.fetchYjfx(ssyxm, sszym, code, xslbm,xwccm)
      }else{
        this.$set(this.selectMenu, 'yjfx', [])
      }
    },
    xslbChange (code) {
      this.form.setFieldsValue({yjfx: ''})
      if(code){
        // 获取研究方向
        let ssyxm = this.form.getFieldValue('ssyxm')
        if(!ssyxm && this.xjxx){
          ssyxm = this.xjxx.ssyxm
        }
        let sszym  = this.form.getFieldValue('sszym')
        if(!sszym && this.xjxx){
          sszym = this.xjxx.sszym
        }
        let sznj  = this.form.getFieldValue('sznj')
        if(!sznj && this.xjxx){
          sznj = this.xjxx.sznj
        }
        let xwccm  = this.getXwccm();
        this.fetchYjfx(ssyxm, sszym, sznj, code,xwccm)
      } else  {
        this.$set(this.selectMenu, 'yjfx', [])
      }
    },
    filterOption (value, op) {
      return op.componentOptions.children[0].text.indexOf(value) !== -1
    },
    fetchYjfx (ssyxm, sszym, zsxn, xslbm,xwccm){
      console.log(ssyxm, sszym, zsxn, xslbm)
      if(ssyxm && sszym && zsxn && xslbm){
        this.$api.base.researchListByDistinct({ssyxm, sszym, zsxn, xslbm,xwccm}).then(res => {
          this.$set(this.selectMenu, 'yjfx', res.data)
        })
      }
    },
    fetchDyds (yxm, zym) {
      if(yxm && zym){
        this.$api.teacher.queryListByStu({yxm: yxm, zym: zym}).then(res => {
          this.$set(this.selectMenu, 'dsList', res.data)
        })
      }
    }
    // ,
    // fetchDeds (e) {
    //   if(value && value.length > 1) {
    //     this.deds.fetching = true
    //     this.$api.teacher.queryListByStu({dwh: '', cx: e}).then(res => {
    //       this.deds.list = res.data
    //       this.deds.fetching = false
    //     })
    //   }
    // }
  }
}
</script>
